package com.sgb.jicai.view.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.TextView;

import com.sgb.jicai.BR;
import com.sgb.jicai.R;
import com.sgb.jicai.entity.OfferAdviceListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * 1.13改版后，此适配器复用
 * 加盟集采、参与报价  页面的 报价指导和加盟指导  复用
 */
public class OfferAdviceListAdapter extends BaseRecycleAdapter<OfferAdviceListEntity> {

    private Context context;

    public OfferAdviceListAdapter(Context context, List<OfferAdviceListEntity> datas) {
        super(context, R.layout.item_offer_advice_list, datas);
        this.context = context;
    }

    @Override
    public void convert(ItemViewHolder holder, OfferAdviceListEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        TextView specificationsmodels = holder.itemView.findViewById(R.id.specifications_models);//规格型号
        if (entity.getAttrs() != null && entity.getAttrs().size() > 0) {
            String stringattr = "";
            for (OfferAdviceListEntity.AttrsBean attr : entity.getAttrs()) {
                if (!TextUtils.isEmpty(attr.getValue())) {
                    stringattr = stringattr + attr.getName() + ":" + attr.getValue() + " ";
                }
            }
            if (!TextUtils.isEmpty(stringattr)) {
                specificationsmodels.setText(stringattr + "");
            } else {
                specificationsmodels.setText("无");
            }
        } else {
            specificationsmodels.setText("无");
        }
    }

}
